GtkTooltip: take csd shadows into account for placement
authorMatthias Clasen <mclasen@redhat.com>
Fri, 6 Jun 2014 21:15:18 +0000 (17:15 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 9 Jun 2014 18:15:28 +0000 (14:15 -0400)
When placing tooltips, we don't want the shadow to influence
our choice.

https://bugzilla.gnome.org/show_bug.cgi?id=731187

gtk/gtktooltip.c

index 0d284af7eae248db5a3eaf219e2f5c1cdb8552ea..5aabf42917ec84e239680ae99d8034ee4eb4b782 100644 (file)
@@ -980,6 +980,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
   GdkRectangle monitor;
   guint cursor_size;
   GdkRectangle bounds;
+  GtkBorder border;
 
 #define MAX_DISTANCE 32
 
@@ -990,8 +991,10 @@ gtk_tooltip_position (GtkTooltip *tooltip,
 
   screen = gtk_widget_get_screen (new_tooltip_widget);
 
-  width = gtk_widget_get_allocated_width (GTK_WIDGET (tooltip->current_window));
-  height = gtk_widget_get_allocated_height (GTK_WIDGET (tooltip->current_window));
+  _gtk_window_get_shadow_width (GTK_WINDOW (tooltip->current_window), &border);
+
+  width = gtk_widget_get_allocated_width (GTK_WIDGET (tooltip->current_window)) - border.left - border.right;
+  height = gtk_widget_get_allocated_height (GTK_WIDGET (tooltip->current_window)) - border.top - border.bottom;
 
   monitor_num = gdk_screen_get_monitor_at_point (screen,
                                                  tooltip->last_x,
@@ -1133,6 +1136,9 @@ found:
         }
 #endif
 
+      x -= border.left;
+      y -= border.top;
+
       gtk_window_move (GTK_WINDOW (tooltip->current_window), x, y);
       gtk_widget_show (GTK_WIDGET (tooltip->current_window));
     }